Skip to content

Conversation

@MuriloFP
Copy link
Contributor

@MuriloFP MuriloFP commented Jun 30, 2025

Related GitHub Issue

Closes: #2728

Description

Summary

Prevents system files like .DS_Store, .Thumbs.db, and other cache files from being processed as rule files in the .roo/rules-{mode-slug} directories.

Changes

  • Added shouldIncludeRuleFile() function to filter out unwanted files during rule compilation
  • Modified readTextFilesFromDirectory() to apply file filtering before processing
  • Added support for 21 common cache file patterns including .DS_Store, .db, .bak, .log, etc.
  • Updated comment to reflect the new filtering behavior

Impact

  • Fixes issue where macOS .DS_Store files were being included in system prompts
  • Prevents other cache and temporary files from polluting rule compilation
  • Improves system prompt quality and reduces noise

Test Procedure

Manual Testing

  • Create a .roo/rules-{mode-slug}/ directory
  • Create a .DS_Store (or other files in the exclusion pattern), add random content like "AAAAAAAAA"
  • Go to Roo modes, click to copy the system prompt for the mode
  • Paste on Notepad, CTRL + F for "AAAAA"

On the current main branch, we see the content from the .DS_Store and other files being added, there's no filter.
With this implementation, the files are filtered and not included in the rules.

  • Test Coverage: Added "should filter out cache files from .roo/rules/ directory" test case
    • Tests filtering of .DS_Store, Thumbs.db, .bak, .log, .tmp, .pyc files
    • Verifies rule files are still processed correctly
    • Confirms cache files are completely excluded from processing
    • Prevents future regressions in filtering logic

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Why we didn't import from existing exclusion patterns:

The existing getCacheFilePatterns() function in src/services/checkpoints/excludes.ts contains identical patterns, but we cannot import from it due to architectural constraints:

  • The custom-instructions.ts file is imported by webview components that run in the browser
  • excludes.ts has Node.js dependencies (fs/promises, path) that cannot be bundled for browser environments
  • Importing from excludes.ts would cause Vite build failures in the webview

This is a necessary architectural trade-off to maintain browser compatibility while solving the cache file inclusion issue.

Let me know if any other changes are needed, or if I should add tests for the filtering logic.

Get in Touch

@MuriloFP


Important

Adds shouldIncludeRuleFile() to filter out cache files from rule compilation in custom-instructions.ts, improving prompt quality.

  • Behavior:
    • Adds shouldIncludeRuleFile() in custom-instructions.ts to exclude cache files like .DS_Store, .Thumbs.db, etc., from rule compilation.
    • Modifies readTextFilesFromDirectory() to use shouldIncludeRuleFile() for filtering files before processing.
  • Impact:
    • Fixes issue with .DS_Store files being included in system prompts.
    • Prevents cache and temporary files from affecting rule compilation.
    • Enhances system prompt quality by reducing noise.

This description was created by Ellipsis for ec62e2f. You can customize this summary. It will automatically update as commits are pushed.

## Summary
Prevents system files like `.DS_Store`, `.Thumbs.db`, and other cache files from being processed as rule files in the `.roo/rules-{mode-slug}` directories.

## Changes
- Added `shouldIncludeRuleFile()` function to filter out unwanted files during rule compilation
- Modified `readTextFilesFromDirectory()` to apply file filtering before processing
- Added support for 21 common cache file patterns including `.DS_Store`, `.db`, `.bak`, `.log`, etc.
- Updated comment to reflect the new filtering behavior

## Impact
- Fixes issue where macOS `.DS_Store` files were being included in system prompts
- Prevents other cache and temporary files from polluting rule compilation
- Improves system prompt quality and reduces noise

## Additional Notes

**Why we didn't import from existing exclusion patterns:**

The existing `getCacheFilePatterns()` function in `src/services/checkpoints/excludes.ts` contains identical patterns, but we cannot import from it due to architectural constraints:

- The `custom-instructions.ts` file is imported by webview components that run in the browser
- `excludes.ts` has Node.js dependencies (`fs/promises`, `path`) that cannot be bundled for browser environments
- Importing from `excludes.ts` would cause Vite build failures in the webview

This is a necessary architectural trade-off to maintain browser compatibility while solving the cache file inclusion issue.

Resolves: RooCodeInc#2728
@MuriloFP MuriloFP requested review from cte, jr and mrubens as code owners June 30, 2025 16:37
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jun 30, 2025
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 30, 2025
…tion

## Summary
Addresses feedback by adding comprehensive test coverage for cache file filtering and simplifying the filtering logic using functional programming patterns.

## Changes
- **Test Coverage**: Added `"should filter out cache files from .roo/rules/ directory"` test case
  - Tests filtering of `.DS_Store`, `Thumbs.db`, `.bak`, `.log`, `.tmp`, `.pyc` files
  - Verifies rule files are still processed correctly
  - Confirms cache files are completely excluded from processing
  - Prevents future regressions in filtering logic

- **Code Simplification**: Refactored `shouldIncludeRuleFile()` function
  - Replaced for loop with `.some()` method for more concise logic
  - Improved functional programming style while maintaining identical behavior
  - Enhanced code readability and maintainability

## Impact
- ✅ 25/27 tests passing with comprehensive cache file filtering coverage
- ✅ More maintainable and testable codebase
- ✅ Prevents future regressions in rule compilation filtering
- ✅ Addresses all reviewer feedback points

## Technical Notes
- Test uses mock file system to simulate various cache file types
- Verifies that `readFileMock` is never called for filtered cache files
- Maintains cross-platform compatibility (Windows/Unix path handling)
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 30, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 30, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 30, 2025
@daniel-lxs
Copy link
Member

Thank you @MuriloFP

I updated the implementation to use an allowlist approach instead of maintaining a blocklist of files to exclude. Now it only accepts known rule file extensions: .md, .txt, .xml, .yaml, .yml, and .json.

This is cleaner and more predictable. We define exactly what we want, rather than trying to try and guess everything we don't. It also solves the original .DS_Store issue, since files like that won't have an allowed extension.

The tests have been updated to reflect this change, and all CI checks are passing.

@daniel-lxs daniel-lxs force-pushed the fix-filter-rules-files branch from eea2620 to cbf0c99 Compare July 1, 2025 12:49
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrubens
I reverted the changes
LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 1, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 1, 2025
@mrubens mrubens merged commit 933f28f into RooCodeInc:main Jul 1, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 1, 2025
hannesrudolph pushed a commit that referenced this pull request Jul 3, 2025
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
chrarnoldus added a commit to Kilo-Org/kilocode that referenced this pull request Jul 4, 2025
utarn pushed a commit to modelharbor/ModelHarbor-Agent that referenced this pull request Jul 4, 2025
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

.DS_Store File in Instruction Files Directory

4 participants